# -*- coding:utf-8 -*-

'''
PROJECT_NAME : python_高级
file    : 元类1
author  : 1032162439@qq.com
date    : 2022-11-08 15:05
IDE     : PyCharm
'''


class MyType(type):
    def __new__(cls, *args, **kwargs):
        # print(cls)  # <class '__main__.MyType'>
        kwargs.update({'test': 'cccafsas'})
        res = super().__new__(cls, *args, **kwargs)
        # print(res)  # <class '__main__.Foo'>
        return res

    def __init__(cls, class_name, class_bases, class_attrs):
        super(MyType, cls).__init__(class_name, class_bases, class_attrs)
        if class_name.__len__() < 5:
            raise ValueError('类名必须大于等于5个字符')

        if not cls.__doc__:
            raise ValueError("必须写注释")


class Foooo(metaclass=MyType):
    "test"
    pass


print(Foooo.__dict__)
